<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
<head>
<title>信息详情</title>
<link rel="stylesheet" href="${ctx}/static/css/jquery-ui.min.css" />
<script src="${ctx}/static/js/jquery-ui.min.js"></script>
<script src="${ctx}/static/layer/layer/layer.js"></script>
<style type="text/css"> 
ul{margin:0px; padding:0px;list-style:none;}
li{margin:0px; padding:0px; list-style:none;}
.clear{clear:both;}
#previewImgs {
	width: 350px;
/* 	height: 300px; */
	list-style: none;
	margin-left:23%;
}

#previewImgs li {
	max-width: 350px;
	height: auto;
	float: left;
	margin: 3px;
}


.myconts {
	width: 90%;
	height: auto;
	margin: 10px auto;
}

.myconts-list {
	width: 100%;
	height: 450px;
	overflow-y: auto;
}

.myconts-list h6 {
	margin: 0;
	line-height: 30px;
}

.myconts-list p {
	margin: 0;
	font-size: 12px;
	line-height: 30px;
}

.myconts-list ul {
	width: 100%;
	height: auto;
	margin: 0;
	padding: 0;
}

.myconts-list ul li {
	font-size: 12px;
}

.myconts-list ul li span {
	line-height: 22px;
	margin-right: 10px;
}

.conts-list {
	margin-left: 10px;
}
.cen{
width:70%;
margin-left:15%;
}
.cen ul{width:100%;}
.zan {height:auto;margin-top:10px;}
.zan li{float:left;width:auto;}
.juse{padding:0 2% 0 2%;}
</style>
</head>

<body>

	<!-- 	<a href="#" onclick="getManagerList('1','1')">点击</a> -->
	<div class="main-content-inner">
		<!-- #section:basics/content.breadcrumbs -->
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try {
					ace.settings.check('breadcrumbs', 'fixed')
				} catch (e) {
				}
			</script>

			<ul class="breadcrumb">
				<li><i class="ace-icon fa fa-home home-icon"></i> <a
					href="${ctx}/welcome">主页</a></li>
				<li class="active">发帖详情</li>
			</ul>
			<!-- /.breadcrumb -->
		</div>

		<div class="page-content">
			<c:if test="${not empty message}">
				<div id="message" class="alert alert-success">
					<button data-dismiss="alert" class="close">×</button>${message}</div>
			</c:if>
			<div class="page-header">
				<h1>信息详情</h1>
			</div>
			<!-- /.page-header -->
			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<div class="row">
						<div class="col-xs-12">
							<a href="#" onclick="history.back();" style="font-size:16px">返回</a>
							<form id="inputForm" action="${ctx}/joinfirm/${action}"
								method="post" class="form-horizontal">
								<input type="hidden" id="customerid" value="${feed.customer.id }"/>
								<h2 style='width:100%;text-align:center;'>${feed.feedTag.name}<span style="font-size:13px;">&nbsp;&nbsp;${feed.customer.user.loginName}</span>
								</h2>

								<h3 style='width:70%;text-align:center; margin-left: 15%;font-size: 13px;'>${feed.content}</h3>
								<div class="preview" style="margin-left: 200px">
									<input id="pics" name="pics" type="hidden">
									<div id="content">									
										<ul id="previewImgs">
											<c:forTokens items="${feed.pics}" delims="|" var="pic">
												<li><img layer-src="${pic}" layer-pid="" src="${pic}" width="100" height="80">
											</c:forTokens>
										</ul>
									</div>
								</div>
								<div class="clear"></div>
								<div class="cen">
								<div  style="margin-top:20px">
									<span><fmt:formatDate value="${feed.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /></span><span style="float: right;margin-right:5%;">${feed.location }</span>
								</div>
								<div class="clear"></div>
								<ul class="zan">
									<li><a href="#" onclick="getLikeList(${feed.id},'1')">点赞${feed.likeCount}</a></li>
									<li class="juse"><a href="#" onclick="getManagerList(${feed.id},'1')">评论${feed.commentCount }</a></li>
									<li><a href="#" onclick="getReportList(${feed.id},'1')">举报${feed.reportCount }</a></li>
								</ul>
								<div class="clear"></div>
								<div class="mask">
									<h5>操作记录:</h5>
									<div class="myconts">
										<div class="myconts-list">
											<ul>
												<c:if test="${not empty delfeed}">																					            <div class="jilu">
										            <span>${fn:substring(delfeed.createDate,0,19)}</span><span style="margin-left:30px">${delfeed.user.loginName}  聊天信息</span>
										                <p>${delfeed.note}</p>
										            </div>
										            <hr style="margin-top:0px;margin-bottom:0px;height:2px;border:none;border-top:2px dotted #185598;" />
<!-- 										            <div class="jilu"> -->
<!-- 										                <span>2016-03-24 13:33:33</span><span style="margin-left:30px">客服01聊天信息</span> -->
<!-- 										                <p>[评论用户+评论内容]</p> -->
<!-- 										                <p>内容涉及违法内容涉及违法内容涉及违法内容涉及违法内容涉及违法</p> -->
<!-- 										            </div> -->
												</c:if>
												<c:if test="${not empty commentlist}">
													<c:forEach items="${commentlist}" var="comment">
											           	 <div class="jilu">
											                <span>${fn:substring(comment.createDate,0,19)}</span><span style="margin-left:30px">${comment.operator}  评论</span>
											                <p>${comment.mlogin}:${comment.mcontent}</p>
											                <p>${comment.note}</p>
											            </div>
											            <hr style="margin-top:0px;margin-bottom:0px;height:1px;border:none;border-top:2px dotted #185598;" />
													</c:forEach>
												</c:if>
											</ul>

										</div>
									</div>
								</div>
								</div>
							</form>

						</div>
						<!-- /.span -->
					</div>
					<!-- /.row -->
				</div>
			</div>

			<!-- 评论的弹框 -->
			<div style="display: none;" class="modal fade bs-example-modal-lg in"
				id="personAddModel" tabindex="-1" role="dialog"
				aria-labelledby="myLargeModalLabel" aria-hidden="false">
				<div class="modal-dialog modal-lg">
					<div class="modal-content" id="personAddModelContent">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal">
								<span aria-hidden="true">×</span><span class="sr-only">Close</span>
							</button>
							<span class="modal-header-title" id="myModalLabel">评论信息</span>
						</div>

						<div class="modal-body">
							<div class="row">
								<div class="col-xs-12" id="managerList"></div>
							</div>
						</div>
						<div class="modal-footer" id="pagination"></div>
					</div>
				</div>
			</div>
			<!-- end 评论弹框 -->
			
			<!-- 点赞的弹框 -->
			<div style="display: none;" class="modal fade bs-example-modal-lg in"
				id="likeAddModel" tabindex="-1" role="dialog"
				aria-labelledby="myLargeModalLabel" aria-hidden="false">
				<div class="modal-dialog modal-lg">
					<div class="modal-content" id="personAddModelContent1">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal">
								<span aria-hidden="true">×</span><span class="sr-only">Close</span>
							</button>
							<span class="modal-header-title" id="myModalLabelLike">点赞信息</span>
						</div>

						<div class="modal-body">
							<div class="row">
								<div class="col-xs-12" id="likeList"></div>
							</div>
						</div>
						<div class="modal-footer" id="paginationlike"></div>
					</div>
				</div>
			</div>
			<!-- end 点赞弹框 -->
			<!-- start 举报的弹框-->
			<div style="display: none;" class="modal fade bs-example-modal-lg in"
				id="reportAddModel" tabindex="-1" role="dialog"
				aria-labelledby="myLargeModalLabel" aria-hidden="false">
				<div class="modal-dialog modal-lg">
					<div class="modal-content" id="personAddModelContent2">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal">
								<span aria-hidden="true">×</span><span class="sr-only">Close</span>
							</button>
							<span class="modal-header-title" id="myModalLabelReport">举报信息</span>
						</div>

						<div class="modal-body">
							<div class="row">
								<div class="col-xs-12" id="reportList"></div>
							</div>
						</div>
						<div class="modal-footer" id="paginationreport"></div>
					</div>
				</div>
			</div>
			<!-- end 举报弹框 -->
			<div id="dialog-delete" class="hide">
	             <div class="form-group">
	                 <div class="col-sm-9">
	                 	<label>请填写原因</label>
	                 </div>
	                 <input type="hidden" id="commentid"/>
	                 <div class="col-sm-9">
	                 	<textarea id="tt_reason" rows="7" cols="60"></textarea>
	                 </div>
	             </div>
	             <p>
	             </p>
	         </div>
		</div>
		<!-- /.page-content -->
	</div>
	<script type="text/javascript">
	layer.ready(function(){
		layer.photos({
			photos:'#previewImgs'
		})
	})
		function getManagerList(dealerId, page2) {
			// 		macAddress = document.getElementById("activeXDemo").getMac();
					$.get("${ctx}/feed/getfeedlist?" + Math.random(),	
							{
								page : page2, //第二页
								pagesize : 20,
								feedId : dealerId
							//贴子id
							// 				  macAddress:macAddress
							},
							function(data) {
								if (data) {
									var managerList = data.content;
									var rs = "";
									var str = "<ul>";
									if(data.content!=undefined){		
										for (var i = 0; i < managerList.length; i++) {
											str += '<li><span>';
													if(managerList[i].replyCustomer==null){
														str+=managerList[i].customer.user.loginName;
													}else{
														str+=managerList[i].customer.user.loginName +' 回复 '+managerList[i].replyCustomer.user.loginName;
													}
													str+= ':</span><span style="margin-left:20px">';
													str+= managerList[i].content;
													str+= '</span><span style="margin-left:10px">';
													str+= convertDate(managerList[i].createDate,0);
													str+= '</span><a href="#" style="color:red;margin-left:15px" onclick="checkDelete('+managerList[i].id+')">&times;</a>';
													str+= '</li>';
										}
// 										<span class="close" aria-label="Close" style="color:red" onclick="alert('测试123')">&times;</span>
									}
									str += "</ul>";
									$('#managerList').empty();
									$('#managerList').append(str);

									var page2 = data.number;
									var stor_no2 = data.stor_no2;
									var pageCount2 = data.totalPages;
									var pagination = "";
									pagination += "<ul class='pagination pager_cus'>";
									pagination = pagination + "<li><a>第 "
											+ (page2 + 1);
									pagination = pagination + " 页/共 "
											+ pageCount2 + " 页</a></li>";

									pagination += "<li><a href='javascript:getManagerList(\"";
									pagination += dealerId;
									pagination += "\",";
									pagination += 1 + ");'>« 首页</a></li>";
									if (page2 > 0) {
										pagination += "<li><a href='javascript:getManagerList(\"";
										pagination += dealerId;
										pagination += "\",";
										pagination += (page2)
												+ ");'>« 上一页</a></li>";
									}

									var start = page2 - 3;
									var end = page2 + 3;
									if (start < 0) {
										end = end - start;
									}
									if (end > (pageCount2 - 1)) {
										end = pageCount2 - 1;
										start = end - 7;
									}
									for (var j = start; j <= end; j++) {
										if (j > -1 && j < pageCount2) {
											if (page2 == j) {
												pagination += "<li  class='active'><a href='javascript:getManagerList(\"";
												pagination += dealerId;
												pagination += "\",";
												pagination += j + 1 + ");'>"
														+ (j + 1) + "</a></li>";
											} else {
												pagination += "<li><a href='javascript:getManagerList(\"";
												pagination += dealerId;
												pagination += "\",";
												pagination += j + 1 + ");'>"
														+ (j + 1) + "</a></li>";
											}

										}
									}

									if (page2 < pageCount2 - 1) {
										pagination += "<li><a href='javascript:getManagerList(\"";
										pagination += dealerId;
										pagination += "\",";
										pagination += (page2 + 2)
												+ ");'>下一页 »</a></li>";
									}
									pagination += "<li><a href='javascript:getManagerList(\"";
									pagination += dealerId;
									pagination += "\",";
									pagination += (pageCount2)
											+ ");'>« 尾页</a></li>";

									$('#pagination').empty();
									$('#pagination').append(pagination);

									$('#personAddModel').modal('show');

								}
							});
		}

		function convertDate(date,flag) {
// 			var date = new Date(date);
// 			var dataStr ="";
// 			if(flag =='1'){ //显示的到分钟
// 				dateStr = date.getFullYear() + '-' + date.getMonth() + '-'
// 				+ date.getDate() + " " + date.getHours() + ":"
// 				+ date.getMinutes()
// 			}else{ // 显示完全时间				
// 				 dateStr = date.getFullYear() + '-' + date.getMonth() + '-'
// 						+ date.getDate() + " " + date.getHours() + ":"
// 						+ date.getMinutes() + ":" + date.getSeconds();
// 			}
// 			return dateStr;
			var d=new Date();
			d.setTime(date);
			var dataStr="";
			if(flag=='1'){
				dataStr=d.format('yyyy-MM-dd hh:mm')
			}else{
				dataStr=d.format("yyyy-MM-dd hh:mm:ss");
			}
			return dataStr;
			
		}
		Date.prototype.format = function(f){
		    var o ={
		        "M+" : this.getMonth()+1, //month
		        "d+" : this.getDate(),    //day
		        "h+" : this.getHours(),   //hour
		        "m+" : this.getMinutes(), //minute
		        "s+" : this.getSeconds(), //second
		        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
		        "S" : this.getMilliseconds() //millisecond
		    }
		    if(/(y+)/.test(f))f=f.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
		    for(var k in o)
		        if(new RegExp("("+ k +")").test(f))f = f.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));return f
		}
		
		function getLikeList(dealerId, page2) {
			// 		macAddress = document.getElementById("activeXDemo").getMac();
					$.get("${ctx}/feed/getlikelist?" + Math.random(),	
							{
								page : page2, //第二页
								pagesize : 20,
								feedId : dealerId
							//贴子id
							// 				  macAddress:macAddress
							},
							function(data) {
								if (data) {
									var managerList = data.content;
									var rs = "";
									var str = "<ul>";
									if(data.content!=undefined){										
										for (var i = 0; i < managerList.length; i++) {
											str += '<li><span>';
											str+= managerList[i][0];
											str+= '</span>';
											str+= '<span style="margin-left:40px">';
											str+= '点了一个赞';
											str+= '</span><span style="margin-left:80px">';
											str+= convertDate(managerList[i][1],1);
											str+= '</span></li>';
										}
									}
									str += "</ul>";
									$('#likeList').empty();
									$('#likeList').append(str);

									var page2 = data.number;
									var stor_no2 = data.stor_no2;
									var pageCount2 = data.totalPages;
									var pagination = "";
									pagination += "<ul class='pagination pager_cus'>";
									pagination = pagination + "<li><a>第 "
											+ (page2 + 1);
									pagination = pagination + " 页/共 "
											+ pageCount2 + " 页</a></li>";

									pagination += "<li><a href='javascript:getLikeList(\"";
									pagination += dealerId;
									pagination += "\",";
									pagination += 1 + ");'>« 首页</a></li>";
									if (page2 > 0) {
										pagination += "<li><a href='javascript:getLikeList(\"";
										pagination += dealerId;
										pagination += "\",";
										pagination += (page2)
												+ ");'>« 上一页</a></li>";
									}

									var start = page2 - 3;
									var end = page2 + 3;
									if (start < 0) {
										end = end - start;
									}
									if (end > (pageCount2 - 1)) {
										end = pageCount2 - 1;
										start = end - 7;
									}
									for (var j = start; j <= end; j++) {
										if (j > -1 && j < pageCount2) {
											if (page2 == j) {
												pagination += "<li  class='active'><a href='javascript:getLikeList(\"";
												pagination += dealerId;
												pagination += "\",";
												pagination += j + 1 + ");'>"
														+ (j + 1) + "</a></li>";
											} else {
												pagination += "<li><a href='javascript:getLikeList(\"";
												pagination += dealerId;
												pagination += "\",";
												pagination += j + 1 + ");'>"
														+ (j + 1) + "</a></li>";
											}

										}
									}

									if (page2 < pageCount2 - 1) {
										pagination += "<li><a href='javascript:getLikeList(\"";
										pagination += dealerId;
										pagination += "\",";
										pagination += (page2 + 2)
												+ ");'>下一页 »</a></li>";
									}
									pagination += "<li><a href='javascript:getLikeList(\"";
									pagination += dealerId;
									pagination += "\",";
									pagination += (pageCount2)
											+ ");'>« 尾页</a></li>";

									$('#paginationlike').empty();
									$('#paginationlike').append(pagination);

									$('#likeAddModel').modal('show');

								}
							});
		}

		var types=new Array("其他","骗人的","谣言",'侮辱诋毁','传播色情');  //举报类型
		function getReportList(dealerId, page2) {
					$.get("${ctx}/feed/getreportlist?" + Math.random(),	
							{
								page : page2, //第二页
								pagesize : 20,
								feedId : dealerId
							//贴子id
							// 				  macAddress:macAddress
							},
							function(data) {
								if (data) {
									var managerList = data.content;
									var rs = "";
									var str = "<ul>";
									if(data.content!=undefined){										
										for (var i = 0; i < managerList.length; i++) {
											str += '<li><span>';
											str+= managerList[i].customer.user.loginName;
											str+= '</span>';
											str+='<span style="margin-left:40px">';
											var words=managerList[i].reasonType.split("|"); //举报原因
											for(var j=0;j<words.length;j++){
												if(words[j]!="" && words[j]!=undefined){													
													str+=types[words[j]-1]+'|';
												}
											}
											str+='</span>';
											str+='<span style="margin-left:10px">';
											str+= convertDate(managerList[i].createDate,0);
											str+= '</span><br>';
											str+= '<span>';
											str+=  managerList[i].note;
											str+= '</span>';
											str+='</li>';
										}
									}
									str += "</ul>";
									$('#reportList').empty();
									$('#reportList').append(str);

									var page2 = data.number;
									var stor_no2 = data.stor_no2;
									var pageCount2 = data.totalPages;
									var pagination = "";
									pagination += "<ul class='pagination pager_cus'>";
									pagination = pagination + "<li><a>第 "
											+ (page2 + 1);
									pagination = pagination + " 页/共 "
											+ pageCount2 + " 页</a></li>";

									pagination += "<li><a href='javascript:getReportList(\"";
									pagination += dealerId;
									pagination += "\",";
									pagination += 1 + ");'>« 首页</a></li>";
									if (page2 > 0) {
										pagination += "<li><a href='javascript:getReportList(\"";
										pagination += dealerId;
										pagination += "\",";
										pagination += (page2)
												+ ");'>« 上一页</a></li>";
									}

									var start = page2 - 3;
									var end = page2 + 3;
									if (start < 0) {
										end = end - start;
									}
									if (end > (pageCount2 - 1)) {
										end = pageCount2 - 1;
										start = end - 7;
									}
									for (var j = start; j <= end; j++) {
										if (j > -1 && j < pageCount2) {
											if (page2 == j) {
												pagination += "<li  class='active'><a href='javascript:getReportList(\"";
												pagination += dealerId;
												pagination += "\",";
												pagination += j + 1 + ");'>"
														+ (j + 1) + "</a></li>";
											} else {
												pagination += "<li><a href='javascript:getReportList(\"";
												pagination += dealerId;
												pagination += "\",";
												pagination += j + 1 + ");'>"
														+ (j + 1) + "</a></li>";
											}

										}
									}

									if (page2 < pageCount2 - 1) {
										pagination += "<li><a href='javascript:getReportList(\"";
										pagination += dealerId;
										pagination += "\",";
										pagination += (page2 + 2)
												+ ");'>下一页 »</a></li>";
									}
									pagination += "<li><a href='javascript:getReportList(\"";
									pagination += dealerId;
									pagination += "\",";
									pagination += (pageCount2)
											+ ");'>« 尾页</a></li>";

									$('#paginationreport').empty();
									$('#paginationreport').append(pagination);

									$('#reportAddModel').modal('show');

								}
							});
		}
		
		function checkDelete(feedId){
			$("#tt_reason").val("");
			document.getElementById("commentid").value=feedId;
			var dialog = $("#dialog-delete").removeClass('hide').dialog({
 	              modal: true,
 	              height: 350,width:500 ,
 	              title: "删除信息",
 	              title_html: true,
 	              buttons: [
						{
						    text: "删除",
						    "class": "btn btn-primary btn-xs",
						    click: function () {
						  	 var tempThis = $(this);
						  	//判断不为空且小于50个汉字
						  	if($("#tt_reason").val().length > 0 && $("#tt_reason").val().length < 200) {
						  		$.ajax({
						  			type:'POST',
						  			url:'${ctx}/feed/deletecomment/',
						  			dataType:"json", 
						  			data:{
						            	 'id':$('#commentid').val() ,     
						        		 'reason':$("#tt_reason").val() },
						  			success:function(data) {
						  				alert(data.resMsg);
						  				if(data.resCode == 1) {
						  					tempThis.dialog("close");
						  					window.location.reload();
						  				}
						  			}
						    		});
						  		$(this).dialog("close");
						  		$('#personAddModel').modal('hide');	 			  		
						  	} else {
						  		alert("原因不能为空且需要小于200汉字");
						  	} 
						    }
						},
 	                  {
 	                      text: "取消",
 	                      "class": "btn btn-xs",
 	                      click: function () {
 	                          $(this).dialog("close");
 	                      }
 	                  }
 	              ]
 	          });
		}
	</script>
</body>
</html>
